function plotGif(x,y1,y2,figureName)
fig = figure(1);
nImages = 360;
stepImages  = 10;
%% 设置曲线参数
h1 = animatedline;
h1.Color = 'r';
h1.LineWidth = 1.6;
h1.LineStyle = '-.';
h1.Marker = 'o';
h2 = animatedline;
h2.Color = 'b';
h2.LineWidth = 1.6;
h2.LineStyle = '-';
h2.Marker = '*'

%% 设置图窗参数
hold on
axis([1000*min(x),1000*max(x),min([min(y1) min(y2)]),max([max(y1) max(y2)])])
% xlabel('Distance(mm)');
% ylabel('F(N)');
xlabel('\theta(deg)')
ylabel('\tau (N\cdot m)')
set(gca,'FontSize',20,'Fontname', 'Times New Roman');
for idx = 1:stepImages:nImages
    addpoints(h1,1000*x(idx),y1(idx));
    addpoints(h2,1000*x(idx),y2(idx));
    legend('Analytical Model','Dipole Model')
    frame = getframe(fig);
    im{idx} = frame2im(frame);
    drawnow;
end
close;
%% 进行一个图片的保存
filename = [figureName '.gif'];
for idx = 1:stepImages:nImages
    [A,map] = rgb2ind(im{idx},256);
    if idx == 1
        imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0);
    else
        imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0.1);
    end
end
end